<template>
  <h1>员工列表练习</h1>
  <input type="text" placeholder="请输入员工姓名" v-model="emp.name">
  <input type="text" placeholder="请输入员工工资" v-model="emp.salary">
  <input type="text" placeholder="请输入员工岗位" v-model="emp.job">
  <button @click="addEmp">添加员工</button>
  <hr>
<table border="1">
  <tr>
    <th>员工编号</th>
    <th>员工姓名</th>
    <th>员工工资</th>
    <th>员工岗位</th>
  </tr>

  <tr v-for="(e,index) in arr">
    <td>{{index+1}}</td>
    <td>{{e.name}}</td>
    <td>{{e.salary}}</td>
    <td>{{e.job}}</td>
  </tr>
  </table>


</template>
<script setup>
import { ref } from 'vue';
const emp = ref({name:'',salary:'',job:''});
const arr = ref([]);
const addEmp = ()=>{
  if(em.value.name.trim()=='' || emp.value.salary.trim()=='' || emp.value.job.trim()==''){
    alert('请填写完整信息')
    return;
  }
  arr.value.push(emp.value);
  emp.value = {name:'',salary:'',job:''};
}
</script>

<script setup>

</script>



<style scoped>

</style>